﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>8.URL重写配置</title>
    <script type="text/javascript" src="../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushJScript.js"></script>
    <link type="text/css" rel="stylesheet" href="../Content/highlighter/styles/shCoreDefault.css"/>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
	<h3>URL重写</h3>
    <p>
    config.json中的rewriteDirectory,rewriteFile
    </p>
    目录重写,把/1开始的url全改为以/news（文章）开头
    <pre class="brush: javascript;">
    "rewriteDirectory": [
        {"from":"/news/","to":"/1/"}
    ]
    </pre>
    文件重写,把/1/1.html重写为/1/index.html
    <pre class="brush: javascript;">
    "rewriteFile": [
		{ "from":"/1/1.html", "to":"/1/index.html" }
	  ]
    </pre>
    <p>
        经过上面两个规则，请求的路径<br />
        /news/index.html被重写为/1/1.html<br />
        /news/2.html被重写为/1/2.html<br />
        /news/3.html被重写为/1/3.html<br />
        ....<br />
        /news/n.html被重写为/1/n.html<br />
    </p>
</body>
</html>
